export class TCanvasTextureEditor {
    canvas: HTMLCanvasElement;

    constructor(_width = 32, _height=32) {
        this.canvas = document.createElement("canvas");
        this.canvas.width = _width;
        this.canvas.height = _height;
    }
    draw(fun: (ctx: CanvasRenderingContext2D) => void):this {
        const ctx = this.canvas.getContext('2d')
        if (ctx) {
            fun(ctx)
            return this;
        }
        else {
            console.warn("not support canvas 2d)")
            return this;
        }
    }

    preview():this {
        const canvas = this.canvas;
        canvas.style.position = 'fixed';
        canvas.style.top = '25%';
        canvas.style.left = '25%';

        document.body.appendChild(this.canvas)
        return this;
    }

}